1. Field of the Invention
This invention relates to a data processing device and, more particularly, to an improvement of a program control unit used in a data processing device.
2. Background of the Invention
It is well known that a data processing device (for instance, a microcomputer) performs a program constructed by a series of instructions and processes transaction data. The instruction (or instruction word) is the code stored in the memory. The data processing device fetches the coded instruction from the memory, decodes it and performs some operation. An instruction has a meaning peculiar to the data processing device. The various data processing devices provide instruction species ranging from several tens to several hundreds or more. The data processing device normally has a peculiar word length for each instruction. According to the structure of the data processing device, the basic word length varies from several bits to several tens of bits (or over a hundred bits). The code length (bit length) of most instructions is usually the basic word length, and some instructions are multiples of the basic word length.
A program composed of these various instructions in order to perform one job is called a task. A main program consists of several tasks. Usually, this main program has instruction sequences which may be performed a plurality of times during the processing of one or more tasks. These instruction sequences can be grouped into a common program, which results in savings of memory usage and the simplification of the program. This common program is called a subroutine. This subroutine is performed by instruction for calling subroutine in the above main program. This instruction for calling subroutine is usually called a CALL instruction or a JUMP subroutine instruction (hereinafter referred to as a CALL instruction).
This CALL instruction consists of an operation code field and an operand, and the operation code of the CALL instruction is specified in the above operation code field and the entry point of the subroutine to be called is specified in the operand. In this case, the CALL instruction may be a four word instruction (1 word length=4 bits) or more than words four in length.
In this case, however, there is a disadvantage that the execute time is too long, because the instruction contains too many words. Moreover, the number of program steps which can be stored in a fixed storage region (memory) decreases in proportion to the number of stored CALL instructions. Therefore, there has been a disadvantage in that the memory is not used effectively. Three methods have been devised in order to solve such a disadvantage.
One of them is to define a specific region in the memory (which is located continuously) as the region for subroutine storage. If the address is divided into a low location and a high location, the size of this region is so selected that the high location does not vary in size. For instance, in a case that the above address is represented by 8 bits, if the high order 4 bits represents the high location and the low order 4 bits the low location, the size of the region for subroutine storage is 16 words in length. In this case, since the high location bits are always constant, they can be produced by a proper logic circuit. Accordingly, in the operand forming the CALL instruction, it needs the bits designating only the low location.
The second method is to use a fixed low location and a variable high location. In this case, the subroutine storing area is discontinuously assigned to the memory. In this case, it is necessary to designate only the bits comprising the high location by the operand.
A third method is a combination of the first and second methods. The address of the entry point is divided into high, middle and low locations. The bits comprising the high and low locations are fixed and produced by proper logic circuits. The middle location is specified by the operand. For example, when the address is constructed by 8 bits, the upper three bits are assigned to a high location; the lower three bits to the low location; and the middle two bits to the middle location. At this time, the middle two bits are specified by the operand.
In the three methods, the sizes of the storing areas for the subroutine are different one from another. The size of the first method is largest and that of the second method is smallest.
The three methods each enable the CALL instruction to be constructed by one word. In the first method, as the length of one subroutine is longer, the number of the entry points decreases. In this case, it is necessary therefore to jump to the real and effective subroutine area by using a JUMP instruction. Also in the first method, the real and effective subroutine area is separately provided and a plurality of JUMP instructions have designated entry points of the respective subroutines set therein.
In the second method, the entry points of the subroutines are dispersed in the memory and because of this care must be taken when the subroutines are placed in the subroutine specifying regions. That is to say, when a subroutine exceeds the memory capacity of the specifying area, the subroutine overflows. Thus, it must be branched, by using a branch instruction, to another subroutine specifying area or an empty area in the memory. In this case, the main program is interrupted and it is frequently difficult to change the main program.
In the third method, there is no interruption of the main program. However, since the memory capacity from one entry point to the next entry point is small (although it is large in the first method), the use of a subroutine with an excessively large capacity must be avoided in order to prevent the overflow thereof.